﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FifaChamps.API.Data
{
    public static partial class DataManager
    {
        public static int Add_Team(string name, int? rating)
        {
            using (var db = DataManager.FifaDB())
            {
                var result = db.SP_Add_Team(name, rating).First();
                return result.TeamID.Value;
            }
        }

        public static int Update_Team(int teamid, string name, int? rating)
        {
            using (var db = DataManager.FifaDB())
            {
                var result = db.SP_Update_Team(teamid, name, rating).First();
                return result.TeamID.Value;
            }
        }

        public static Team Get_Team(int teamid)
        {
            using (var db = DataManager.FifaDB())
            {
                var result = db.FCT_Teams.Where(team => team.ID == teamid).First();
                return Team.Factory(result.ID, result.TeamName, result.Rating);
            }
        }
    }
}
